#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H

#include <QObject>
#include <QSettings>
#include <QDateTime>
#include <QVector>

struct LevelProgress {
    bool completed;
    QDateTime completionTime;
    int attempts;
    int bestTime; // in seconds
    QDateTime lastPlayed;
};

struct GameProgress {
    int currentLevel;
    QHash<int, LevelProgress> levelProgress;
    QDateTime lastSaved;
};

class GameManager : public QObject
{
    Q_OBJECT

public:
    static GameManager& instance();
    
    void saveProgress();
    void loadProgress();
    
    void levelCompleted(int level, int timeTaken);
    void levelAttempted(int level);
    void setCurrentLevel(int level) { m_progress.currentLevel = level; }
    
    GameProgress getProgress() const { return m_progress; }
    LevelProgress getLevelProgress(int level) const;
    bool isLevelCompleted(int level) const;
    int getCompletedLevelCount() const;
    
    void resetProgress();

private:
    GameManager(QObject *parent = nullptr);
    GameManager(const GameManager&) = delete;
    GameManager& operator=(const GameManager&) = delete;
    
    GameProgress m_progress;
    QSettings m_settings;
};

#endif